package com.ts.conch.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@TableName(value = "ts_admin")
@Data
public class TsAdmin implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id，--主键、自增")
    private String id;

    @ApiModelProperty(value = "admin名称")
    private String name;

    @ApiModelProperty(value = "头像地址")
    private String avatar;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "明文密码")
    private String pw;

    @ApiModelProperty(value = "手机号")
    private String phone;

    @ApiModelProperty(value = "所属角色id")
    private String roleId;

    @ApiModelProperty(value = "账号状态(1=正常, 2=禁用)")
    private Integer status;

    @ApiModelProperty(value = "创建自哪个管理员")
    private Long createByAid;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "上次登陆时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginTime;

    @ApiModelProperty(value = "上次登陆IP")
    private String loginIp;

    @ApiModelProperty(value = "登陆次数")
    private Integer loginCount;

    @TableField(exist = false)
    private String enterpriseId;

    public String getPw() {
        //明文密码不可暴露
        return "***************";
    }
}